package com.zbs.framework.swagger.entity.doc;

import com.zbs.framework.swagger.entity.RequestParams;
import com.zbs.framework.swagger.utils.ApiTypeUtil;
import lombok.Data;
import org.springframework.util.StringUtils;

@Data
public class GroupApiParam {
    private String name;
    private String describe;
    private String required;
    private String array;
    private String dataType;

    public GroupApiParam(RequestParams params,String apiName) {
        if (StringUtils.hasLength(apiName)) {
            this.name = String.format("%s.%s",apiName,params.getName());
        }else {
            this.name = params.getName();
        }
        this.describe = params.getDescribe();
        this.required = params.isRequired() ? "是" : "";
        this.array = params.isArray() ? "array" : "";
        this.dataType = ApiTypeUtil.getDataType(params.getDataType());
    }
}
